<template>
	<view :class="modalName ? 'prevents' : ''">
		<!-- <uni-load v-if="loading"></uni-load> -->
		<!-- <view v-else> -->
			<!-- 请求超时 -->
			<!-- <uni-timeOut v-if="timeOut"></uni-timeOut> -->
			<!-- <view v-else>
				<view v-if="goods.length>0">
					<view class="padding-top-xl padding-lr padding-bottom-sm">Data Plan</view>
					<view v-for="mes in goods">
						<uni-list-item type="2" :list="mes.specifications" titleClass="text-primary text-lg" subTextClass="text-xs text-gray" cuItemStyle="min-height:4.6rem">
							<template #action="{item}">
								<button class="bg-primary text-white cu-btn sm" @tap="goodsClick(item,mes)">Recharge</button>
							</template>
						</uni-list-item>
					</view>
				</view>
				<uni-data v-else :content="$t('buy.empty')"></uni-data>
			</view> -->
		<!-- </view> -->
		<!-- 须知 -->
		<purchaseNote-modal v-model:modalName="modalName" :message="buyMessage" :iccid="urlParams.deviceId" @click="handlebuy"></purchaseNote-modal>
		<!-- 套餐购买详情弹框 bottomModal-->
		<!-- <detail v-model:modalName="modalName" :urlParams="urlParams" :paid="buyMessage" :payType="typeList" :specifications="specifications" :country="country" :isIccid="true" @selectBuyNum="goodsClick"></detail> -->
		<!-- 有未完成订单 弹框 payFail-->
		<!-- <pay-fail v-model:modalName="modalName"></pay-fail> -->
		<!-- 支付加载 模态框 -->
		<!-- <load-modal v-if="loadModal"></load-modal> -->
		<!-- 失败弹框 -->
		<!-- <error-modal v-model:modalName="modalName" :errCode="errCode" :message="errMessage"></error-modal> -->
	</view>
</template>

<script>
import purchaseNoteModal from './purchaseNotes/purchaseNotes'
// import orderStatusOrPayType from '@/jvss/pageCloud/utils/pay.js'
// import { handleMax } from '@/utils/index.js'
export default {
	components: {
	   purchaseNoteModal
	},
    data() {
		return {
				urlParams: {
					deviceId: '',//89852240400010010814
					classifyId: 'global.net.cellular'
				},
				loading: true, //页面进入的加载
				timeOut: false, //接口请求是否超时
				typeList:[],//通过后台获取支付列表
				goods:[],//套餐列表
				modalName:'',
				errCode:'',//失败code值
				errMessage:{},//失败接口返回的data信息
				loadModal:false,//支付加载模态框
				specifications:[],//规格
				goodClickPaid:{},//外部套餐点击获取的数据
				buyMessage:{},//购买计算信息
				country:''
		}
    },
    onLoad(e) {
        this.urlParams.deviceId = e.deviceId;
    },
    onShow() {
		// 订单列表
		handleGoods();
		//支付类型
		handlePayType(this.urlParams,(data)=>{
			const {country,payTypes} = data;
			this.typeList = payTypes;
			this.country = country;
			
		})
	},
    methods: {
		// [获取]套餐列表
		handleGoods(clearCache = false) {
			this.loading = true; //加载中
			let params = Object.assign({},this.urlParams,{clearCache})
			// getGoods(params).then(res => {
			// 	this.loading = false; //停止加载
			// 	this.timeOut = false;
			// 	httpReturn(res, (data) => {
			// 		this.goods = data || []; //数据
			// 		this.goods.forEach((t) => {
			// 			t.specifications = t.specifications || [];//规格
			// 			t.specifications.forEach((z) => {
			// 				z.check = false;
			// 				z.name = t.name;
			// 				z.title = t.name;
			// 				z.subText = t.introduce;
			// 			});
			// 		});
			// 	}, (code,data) => {
			// 		this.modalName = 'errorMessage';//接口返回错误弹框
			// 		this.errCode = code;
			// 		this.errMessage = data;//接口返回的错误data
			// 	})
			// })
		},
		// 选择套餐
		goodsClick (paid,item){
			this.modalName = 'purchaseNotesModal';
			if(item){
				this.specifications = item.specifications;//规格
				this.goodClickPaid = paid;//套餐点击获取的数据
			}
			handlePrice(paid)
		},
		// 购买价格计算
		handlePrice(paid,couponId_){
			const { id, buyNum } = paid;
			const {deviceId,channel} = this.urlParams;
			let buyParamsClass = new buyParams(id, deviceId, buyNum, channel,couponId_);
			 this.buyMessage = paid;
			 this.buyMessage.payAmount = '--.--';
			// getBuy(buyParamsClass).then((res) => {
			// 	httpReturn(res, (data) => {
			// 		const {coupons,useCouponId,useCouponAmount,currencyUnit} = data;
			// 		this.buyMessage = Object.assign({}, paid, data || {});
			// 		this.buyMessage.selectCouponVal = `-${currencyUnit}${useCouponAmount}`//选择的优惠券价格
			// 		this.buyMessage.selectCouponId = useCouponId;//选择的优惠券id
			// 		this.buyMessage.MaxVal = handleMax(coupons,'couponAmount')//获取优惠券最大值
			// 	}, (code) => {
			// 		this.modalName = 'errorMessage';//接口返回错误弹框
			// 		this.errCode = code;
			// 	})
			// });
		},
		// 套餐确认
		handlebuy(){
			this.modalName = 'bottomModal';//弹出购买详情
		}
    }
}
</script>

<style>
</style>